﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ControlTemplate x:Key="DockPaneTemplate"
                     TargetType="{x:Type HeaderedContentControl}">
        <DockPanel>
            <Border x:Name="PART_DOCK_PANE_HEADER"
                    DockPanel.Dock="Top"
                    BorderThickness="0"
                    CornerRadius="2,2,0,0"
                    Background="{TemplateBinding Background}">
                <DockPanel>

                    <Button x:Name="PART_CLOSE"
                            DockPanel.Dock="Right"
                            Style="{DynamicResource DockPaneButton}"
                            Margin="0,0,4,0"
                            VerticalAlignment="Center">

                        <Path Height="16"
                              Width="16"
                              Data="M4,4 L12,12 M12,4 L4,12"
                              Stroke="{DynamicResource DockPaneHeaderForegroundBrush}" />
                    </Button>

                    <ToggleButton x:Name="PART_PIN"
                                  DockPanel.Dock="Right"
                                  Style="{DynamicResource DockPaneButton}"
                                  Margin="0,0,4,0"
                                  VerticalAlignment="Center"
                                  RenderTransformOrigin="0.5,0.5"
                                  RenderTransform="{x:Null}">

                        <Path Height="16"
                              Width="16"
                              Data="M6,4 L10,4 10,10 6,10z M4,11 L12,11 M8,10 L8,14 M9,4 L9,10"
                              Stroke="{DynamicResource DockPaneHeaderForegroundBrush}" />
                    </ToggleButton>

                    <Button x:Name="PART_DOCK_PANE_MENU"
                            DockPanel.Dock="Right"
                            Style="{DynamicResource DockPaneButton}"
                            Margin="0,0,4,0"
                            VerticalAlignment="Center">

                        <Path Fill="{DynamicResource DockPaneHeaderForegroundBrush}"
                              Height="16"
                              Width="16"
                              Data="M4,6 L12,6 8,10 z" />
                    </Button>

                    <ContentPresenter Margin="4"
                                      TextElement.Foreground="{DynamicResource DockPaneHeaderForegroundBrush}"
                                      VerticalAlignment="Center"
                                      ContentSource="Header">
                        <ContentPresenter.Resources>
                            <Style TargetType="{x:Type TextBlock}"
                                   BasedOn="{StaticResource {x:Type TextBlock}}">
                                <Setter Property="TextTrimming"
                                        Value="CharacterEllipsis" />
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                </DockPanel>
            </Border>
            <Border BorderThickness="1"
                    BorderBrush="{TemplateBinding BorderBrush}">
                <ContentPresenter />
            </Border>
        </DockPanel>

        <ControlTemplate.Triggers>
            <Trigger SourceName="PART_PIN"
                     Property="IsChecked"
                     Value="True">
                <Setter Property="RenderTransform"
                        TargetName="PART_PIN">
                    <Setter.Value>
                        <RotateTransform Angle="90" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
        
    </ControlTemplate>
</ResourceDictionary>